<?php

namespace Admin\Model;

use Think\Model;

/**
 * Description of AdminModel
 *
 * @author xtceetg
 */
class CpsModel extends Model {

    protected $tableName = "cps_member";

    public function getSupercps() {
        return $this->where('pid=0')->select();
    }

    public function getChildcps($pid) {
        return $this->where("pid='%d'",$pid)->select();
    }

    public function formatCpsMember() {
        $supercps = $this->getSupercps();
        for ($i = 0; $i < count($supercps); $i++) {
            $child=$this->getChildcps($supercps[$i]['id']);
            $supercps[$i]['child'][]=$child;
        }
        
        return $supercps;
    }

}
